package com.dtream.easycode.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dtream.easycode.entity.TbItem;
import com.dtream.easycode.service.TbItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 商品表(TbItem)表控制层
 *
 * @author makejava
 * @since 2021-01-07 11:28:16
 */
@RestController
@RequestMapping("tbItem")
public class TbItemController {
    /**
     * 服务对象
     */

    private final TbItemService tbItemService;

    @Autowired
    public TbItemController(TbItemService tbItemService) {
        this.tbItemService = tbItemService;
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public TbItem selectOne(Long id) {
        return this.tbItemService.queryById(id);
    }

    /**
     * 分页条件查询
     */
    @GetMapping("/queryItem")
    public Page<TbItem> queryItem(TbItem tbItem) {
        return tbItemService.queryItem(tbItem);
    }
}